package com.niuwa.p2p.action.producttemplate;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.niuwa.p2p.action.JsonAction;
import com.niuwa.p2p.service.productTemplate.ProductService;
import com.niuwa.p2p.vo.business.ProductVo;
import com.opensymphony.xwork2.ActionContext;

@Controller
public class ProductAction extends JsonAction{
	
	private String tempId;
	
	private List<ProductVo> products;
	
	@Autowired
	private ProductService productService;
	
	/**
	 * 关联产品列表
	 * 
	 * @return
	 * @throws Exception
	 */
	@Action(value = "gotoAssociateProductList")
	public String associateProductList() throws Exception {
//		Long tempId = Long.valueOf(111);
		if (null != tempId && !"".equals(tempId)) {
			Long _tempId = Long.valueOf(tempId);
			// 执行查询操作
			products = productService.selectProductByTempId(_tempId);
			ActionContext context = ActionContext.getContext();
			context.put("products", products);
			//setObjectReSult(products);
		}
		return "associatedProductList";
	}
	
	/**
	 * 关联产品列表(借款)
	 * 
	 * @return
	 * @throws Exception
	 */
	@Action(value = "gotoLoanAssociateProductList")
	public String loanAssociateProductList() throws Exception {
//		Long tempId = Long.valueOf(111);
		if (null != tempId && !"".equals(tempId)) {
			Long _tempId = Long.valueOf(tempId);
			// 执行查询操作
			products = productService.selectProductByTempId(_tempId);
			ActionContext context = ActionContext.getContext();
			context.put("products", products);
			
			//setObjectReSult(products);
		}
		return "associatedProductList";
	}
	
	@Action("getNewAudit")
	public String getNewAudit(){
		Integer tempId = Integer.parseInt(this.getParam("tempId"));
		this.setResult(true, null, productService.getNewstAudit(tempId));
		return NONE;
	}

	public List<ProductVo> getProducts() {
		return products;
	}

	public void setProducts(List<ProductVo> products) {
		this.products = products;
	}

	public String getTempId() {
		return tempId;
	}

	public void setTempId(String tempId) {
		this.tempId = tempId;
	}

}
